package com.yorick.netty.messageListener;

import io.netty.channel.ChannelHandlerContext;

import java.lang.reflect.Method;

public class Listener {

    public Object getListener(Integer msgId, byte[] msgBody, ChannelHandlerContext ctx){
        try {
            Register register = Register.getInstance();
            Object obj = register.objectMap.get(msgId);
            Method method = register.methodMap.get(msgId);
            Object[] arguments = new Object[] {msgBody,ctx};
            method.invoke(obj , arguments);
            return method;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
